home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6989 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.4 KB  |  63 lines

  1. Newsgroups: comp.lang.c++
  2. Path: cs.dal.ca!ug!mzhang
  3. From: mzhang@ug.cs.dal.ca (MAONI ZHANG)
  4. Subject: Mastermind 
  5. Message-ID: <Dn4Eyq.Kpw@cs.dal.ca>
  6. Sender: usenet@cs.dal.ca (USENET News)
  7. Nntp-Posting-Host: ug.cs.dal.ca
  8. Organization: Math, Stats & CS, Dalhousie University, Halifax, NS, Canada
  9. X-Newsreader: TIN [version 1.2 PL2]
  10. Date: Wed, 21 Feb 1996 10:11:13 GMT
  11.  
  12. Hello All,
  13.  
  14. I can't figure out a good way to programm mastermind, here's the description
  15. of it:
  16.  
  17. /* beginning of the description */
  18.  
  19.  
  20. Mastermind is a popular children's game. One player is the "codemaker"
  21. M who chooses a code represented by four coloured pegs. The other
  22. player is the "code-breaker" B who is allowed up to 10 guesses at the
  23. code. B wins if (s)he guesses the code within 10 trys otherwise M wins.
  24. It may also be interesting to keep track of statistics on the number of
  25. guesses required.
  26.  
  27. After each guess M reports a score which contains partial information.
  28. The score has two parts, viz, the number of exact matches and the
  29. number of matches in the wrong position. It helps to consider an
  30. example. Suppose the secret code is (Red White Black Black) and B
  31. guesses (Black Black Red Black).  The score in this case would be one
  32. exact match (the fourth position) and two "other" matches (the first
  33. Black and the third Red in the guess). Note that no coloured peg in the
  34. code can match more than one position in the guess and so the second
  35. Black in the guess has nothing left to match with after the other
  36. matches have been paired off. Scoring is surprisingly difficult for
  37. human players and both players must be adept at it.
  38.  
  39. The question of what strategy he codebreaker B should use to pick
  40. guesses is very interesting. One strategy for B is to consider
  41. all possible guesses and to reject those that are inconsistent
  42. with previous guesses. An consistent guess is one which when
  43. scored against all previous gives the same scores. For example,
  44. after receiving a score of (1 2) for (Black Black Red Black) the guess
  45. (Black Red Black Red) is consistent (scored against (Black Black
  46. Red Black) it would get a score of (1 2)). Most other possible
  47. guesses would be inconsistent and rejected by player B.
  48.  
  49. /* end of the description */
  50.  
  51. The first guess would be repeating the 1st color of the 6 colors(suppose
  52. we need to guess 4 outta 6) for 4 times.
  53.  
  54.  
  55. I couldn't think of a good algorithm to do it. it need to be done in c/c++.
  56.  
  57.  
  58. Please email me at mzhang@ug.cs.dal.ca if you get any idea. Thanks for any
  59. suggestions.
  60.  
  61.  
  62. -Maoni 
  63.